/*
 * Copyright (c) 2020-2021, SERI Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-05-22     Lyons        first version
 */

module pa_fpu_data_pack (
    single_i,
    src_sign_i,
    src_expn_i,
    src_xfrac_i,
    rst_o
    );

`include "pa_fpu_param.v"

input                           single_i;
input                           src_sign_i;
input                           src_expn_i;
input                           src_xfrac_i;
output                          rst_o;

wire                            single_i;
wire                            double_i;
wire                            src_sign_i;
wire [`EXPN_WIDTH:0]            src_expn_i;
wire [`FRAC_WIDTH:0]            src_xfrac_i;
wire [`FLOAT_WIDTH-1:0]         rst_o;


wire [`FLOAT_WIDTH-1:0]         rst_single;
wire [`FLOAT_WIDTH-1:0]         rst_double;


assign double_i = ~single_i;

assign rst_single[`FLOAT_WIDTH-1:0] = {32'hffff_ffff, src_sign_i, src_expn_i[7:0],  src_xfrac_i[51:29]};
assign rst_double[`FLOAT_WIDTH-1:0] = {               src_sign_i, src_expn_i[10:0], src_xfrac_i[51:0]};

assign rst_o[`FLOAT_WIDTH-1:0] = {{`FLOAT_WIDTH}{single_i}} & rst_single[`FLOAT_WIDTH-1:0]
                               | {{`FLOAT_WIDTH}{double_i}} & rst_double[`FLOAT_WIDTH-1:0];

endmodule